-
Notifications
You must be signed in to change notification settings - Fork 934
NH-2285 - Support for LockMode in Linq provider #530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@hazzik What would be the way to fix the caching issue exposed by QueryLock.CanChangeLockModeForQuery()? |
It seems the locking is not applied when paging is also used in the query on MSSQL 2008 dialect. |
I don't think that any of the databases support locking with paging. |
I'd like to throw in this old thread into the discussion: |
I'll have another go at this. |
74f6937
to
9bc4e6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SQLite does not seem to support a locking mechanism. Its dialect does override Dialect.ForUpdateString
to an empty string and does not overrides locking methods to supply an alternative way of locking.
Firebird accepts for update
in its syntax but does not do much of it, as explained in its documentation. So in effect it does not actually lock the row. For this, the with lock
clause should be used in Firebird, but they strongly advise against it. And its current NHibernate dialect does not use it.
So it seems to me we need an additional TestDialect
property for stating if locking row is supported by the dialect, and if not, disable the AssertSeparateTransactionIsLockedOut
check. (Or maybe disable the whole fixture.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
using (var s2 = OpenSession()) | ||
using (s2.BeginTransaction()) | ||
{ | ||
// TODO: We should try to verify that the exception actually IS a locking failure and not something unrelated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better, but it does not seem critical to me.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
- Add test case to verify that a change in lock mode will avoid reusing cached query.
- Rename SetLockMode to WithLock - Add overload to support locking on collections in the query - Restrict tests only to dialects that do support locks - Ignore paging tests if dialect does not support combining locks with paging
@hazzik, I am not merging this as I do not know how you intent this to be merged. I would tend to squash and add Oskar and you as co-authors, but as you have rebased this to three commits, I wonder if you were willing to merge this as-is. |
I'm just not sure who will be the main author of the commit when it's got squashed: the PR is made by Oskar with the changes originated from Onur. |
It would surprise me if it will not be the first commit author, so Onur. |
Yes, I was going to investigate this first (what you've already done). |
This is a rebased and updated version of PR #304 to implement support for setting lock mode on LINQ queries.
A notable difference is that the provided test cases have been improved to verify that the locking actually happens. This seems to show that they in fact do NOT take effect on certain dialects (at least MSSQL2008) when paging is also used. That may not be a flaw of this patch though, perhaps it's a deeper problem that affects HQL too?
Fixes #968